package vote.ai.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vote.ai.domain.dto.CorrectionReq;
import vote.ai.domain.vo.CorrectTaskResp;
import vote.ai.domain.vo.CreateCorrectTaskResp;
import vote.ai.factory.CorrectionFactory;

/**
 * Description:
 * Author:han
 * Date: 2024-05-21
 */
@RestController
@Tag(name = "文本纠错管理")
public class CorrectionController {
    @Resource
    private CorrectionFactory correctionFactory;

    @Operation(summary = "创建纠错任务")
    @PostMapping("/create/task")
    public CreateCorrectTaskResp createCorrectionTask(@RequestBody @Validated CorrectionReq req) {
        return this.correctionFactory.createCorrectTask(req.getText());
    }
    @Operation(summary = "获取纠错任务结果")
    @GetMapping("/task/{taskId}")
     public CorrectTaskResp getCorrectTask(@PathVariable String taskId){
         return this.correctionFactory.getCorrectTask(taskId);
    }
}
